package com.example.myblogserver.service.impl;

import com.example.myblogserver.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EamilServiceImpl implements EmailService {

    @Autowired
    private JavaMailSender javaMailSender;

    @Override
    public void sendEmail(String to, String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setSubject("您的验证码");
        message.setText("您的验证码是：" + content + "，请勿泄露给他人。");
        message.setFrom("2817429207@qq.com"); // 发件人邮箱

        javaMailSender.send(message);
    }
}
